<?php
/**
 * 年龄检查
 * User: GRAY
 * Date: 16/8/11
 * Time: 下午10:23
 */

namespace Home\Common\Hook;


use Common\Library\BusinessException;
use Common\Library\Constant;
use Common\Vendor\Hook\BaseHook;
use Think\Log;


class Nation extends BaseHook
{

    public function execute($data, $params = [])
        {
            $id_num = $data['id_num'];
            $nation_pass = $data['nation_pass'];
            if($nation_pass==1) {
                return $data;
            }
	    $nation = ""; 
	    if(isset($data["nation"])){
		$nation  = $data["nation"];
	    }
                //Log::write("Customer contact:".$contactCount, Log::INFO);
	    if($params["key"] == 'include'){
	        if(!in_array($nation, $params["include"])){
	                BusinessException::throwException(Constant::INVALID_NATION);
	        }
	    }else if($params["key"] == 'not_include'){
	        if(in_array($nation, $params["not_include"])){
	                BusinessException::throwException(Constant::INVALID_NATION);
	        }
            }
            return $data;
        }
} 
